package ezonsport.android.ui.stepSystem.dataView;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Display;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;

import ezonsport.android.R;
import ezonsport.android.common.eventManger.MyEventManager;
import ezonsport.android.common.eventManger.Observer;
import ezonsport.android.core.stepSystem.StepData;
import ezonsport.android.data.DataHelper;
import ezonsport.android.service.BluetoothService;
import ezonsport.android.ui.stepSystem.dataDetail.DataDetailActivity;

public class DataViewActivity extends OrmLiteBaseActivity<DataHelper> implements
		OnTouchListener, OnGestureListener,Observer {
	private static final String TAG = "DataViewActivity";
	private TextView tx_date;
	private LinearLayout layout;
	private DataDrawView m_drawView;
	GestureDetector mGestureDetector;
	//数据同步按钮
	private Button btn_syc;
	private ImageView mDataSyncImage;
	
	//数据细节按钮
	private ImageView mDataDetailImage;

	// Constant used for Gesture Move Distance
	private int verticalMinDistance = 20;
	private int minVelocity = 0;

	private Calendar m_Calendar;
	private Calendar m_3daysBefore;
	private Calendar m_LastestDay;
	private int m_year;
	private int m_month;
	private int m_day;

	// private WSGetStepData m_wsGetStepData;
	private Map<Date, Integer> m_datamap;
	private String m_user;

	//private SportDataModel and Controller;
	private StepDataViewModel m_stepModel;
	private StepDataViewController m_stepController;
	private Map<Date, Integer> m_goalMap;

	//蓝牙服务
	private BluetoothService bluetoothService;
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.dataview);
		
		//初始化蓝牙服务
		bluetoothService=new BluetoothService(this);
		
		
		//监听蓝牙手表数据传输过程的事件
		
		MyEventManager.Register(this, BluetoothService.DEVICE_NOTFOUND);
		MyEventManager.Register(this, BluetoothService.BLUETOOH_DISABLE);
		MyEventManager.Register(this, BluetoothService.DoPairFail);
		MyEventManager.Register(this, BluetoothService.DoPairSucess);
		MyEventManager.Register(this, BluetoothService.FILE_SENDING);
		MyEventManager.Register(this, BluetoothService.SEARCHING);
		MyEventManager.Register(this, BluetoothService.DEVICE_FOUND);
			
		layout = (LinearLayout) findViewById(R.id.dataviewlayout);
		tx_date = (TextView) findViewById(R.id.tx_date);
		// m_drawView = (DataDrawView)findViewById(R.id.dataviewcanvas);
       
		//
		mDataSyncImage = (ImageView)findViewById(R.id.dataview_image_reload);
		mDataSyncImage.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				bluetoothService.searchDevice();
			}
		});
		
		mDataDetailImage = (ImageView)findViewById(R.id.dataview_image_datadetail);
		mDataDetailImage.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
		    	intent.setClass(DataViewActivity.this, DataDetailActivity.class);
		    	startActivity(intent);
			}
		});
		
//		TimeZone defaultZone = TimeZone.getDefault();
//		m_Calendar = Calendar.getInstance(defaultZone);
		m_Calendar = Calendar.getInstance();
		m_LastestDay = (Calendar) m_Calendar.clone();
		// Display the label date text
		DateDisplay();

		m_stepController = new StepDataViewController(getHelper());
		Calendar tempCalendar = (Calendar)m_Calendar.clone();
		tempCalendar.add(Calendar.DATE, -30);
		//m_stepController.addStepToDB(tempCalendar.getTime(),m_Calendar.getTime(), 5000);
		m_stepModel = m_stepController.GetStepDataViewModel(tempCalendar.getTime(),m_Calendar.getTime());
		m_datamap = m_stepModel.getStepDataMap();
		//loadData();
		//testMap();
		m_stepModel = m_stepController.getGoalByDate(tempCalendar.getTime(),m_Calendar.getTime());
		m_goalMap = m_stepModel.getStepGoalMap();

		m_drawView = new DataDrawView(this);
		m_drawView.setCurCalendar(m_Calendar);
		//m_drawView.setGoal(3000);
		// setSteps called must behind setCurCalendar();
		m_drawView.setSteps();
		layout.addView(m_drawView, new LinearLayout.LayoutParams(
				LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

		m_user = "qqq";

		// m_drawView.setDataMap(m_datamap);

		mGestureDetector = new GestureDetector(this);
		// You need two methods
		m_drawView.setOnTouchListener(this);
		m_drawView.setLongClickable(true);

	}

	private void DateDisplay() {
		m_3daysBefore = (Calendar) m_Calendar.clone();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String curday = format.format(m_3daysBefore.getTime());
		m_3daysBefore.add(Calendar.DATE, -2);
		String _3daybefore = format.format(m_3daysBefore.getTime());
		tx_date.setText(_3daybefore + "~" + curday);
	}

	private void testMap(){
		for(Map.Entry<Date,Integer> entry:m_datamap.entrySet()){    
		     System.out.println(entry.getKey()+"--->"+entry.getValue());    
		}  
	}

	// Load Data from database,notice only the day of m_Calendar equal to
	// database
	/*public void loadData() {
		Calendar calendar = (Calendar) m_Calendar.clone();
		Random random = new Random();
		for (int i = 0; i < 30; i++) {
			m_datamap.put(calendar.getTime(), random.nextInt(500));
			calendar.add(Calendar.DATE, -1);
		}
	}*/

	Map<Date, Integer> getStepHashMap() {
		return m_datamap;
	}
	Map<Date, Integer> getGoalHashMap(){
		return m_goalMap;
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		boolean returnValue = mGestureDetector.onTouchEvent(event);
		// m_drawView.setFocusable(true);
		return m_drawView.onTouchEvent(event);
	}

	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
			float velocityY) {
		Log.v(TAG, "onFling");
		// Move to left
		if (e1.getX() - e2.getX() > verticalMinDistance
				&& Math.abs(velocityX) > minVelocity) {

			// �л�Activity
			// Intent intent = new Intent(ViewSnsActivity.this,
			// UpdateStatusActivity.class);
			// startActivity(intent);
			// Toast.makeText(this, "��������", Toast.LENGTH_SHORT).show();
			m_Calendar.add(Calendar.DATE, +3);
			if (m_Calendar.after(m_LastestDay))
				m_Calendar.add(Calendar.DATE, -3);
			else {
				DateDisplay();
				// Random random = new Random();
				// drawView.setSteps(200 + random.nextInt(500));
				m_drawView.setCurCalendar(m_Calendar);
				m_drawView.setSteps();
				m_drawView.invalidate();
			}
		}// Move to right
		else if (e2.getX() - e1.getX() > verticalMinDistance
				&& Math.abs(velocityX) > minVelocity) {

			// �л�Activity
			// Intent intent = new Intent(ViewSnsActivity.this,
			// UpdateStatusActivity.class);
			// startActivity(intent);
			// Toast.makeText(this, "��������", Toast.LENGTH_SHORT).show();
			m_Calendar.add(Calendar.DATE, -3);
			DateDisplay();

			// drawView.setSteps(200 + random.nextInt(500));
			m_drawView.setCurCalendar(m_Calendar);
			m_drawView.setSteps();
			m_drawView.invalidate();
		}

		return false;
	}

	@Override
	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
			float distanceY) {
		return false;
	}

	@Override
	public void onLongPress(MotionEvent e) {

	}

	@Override
	public void onShowPress(MotionEvent e) {

	}

	@Override
	public boolean onSingleTapUp(MotionEvent e) {
		return false;
	}

	@Override
	public boolean onDown(MotionEvent e) {
		return false;
	}

	class DataDrawView extends View {
		private final static int messageWhat = 0x1122;
		private int m_width;
		private int m_height;

		//Steps and Goals, 3 day a group 
		private int m_step1;
		private int m_step2;
		private int m_step3;
		private int m_goal1;
		private int m_goal2;
		private int m_goal3;

		private Calendar m_curCalendar;
		private Date m_curDate;
		private Date m_thedaybefore;
		private Date m_3daysbefore;

		private Map<Date, Integer> m_stepMap;
		private Map<Date, Integer> m_goalMap;

		private Animation m_RotateAnimation;
		private Bitmap m_Bmp;

		// Constructor with context param
		public DataDrawView(Context context) {
			super(context);

			WindowManager manager = (WindowManager) context
					.getSystemService(Context.WINDOW_SERVICE);
			Display display = manager.getDefaultDisplay();
			m_width = display.getWidth();
			m_height = display.getHeight();

			m_stepMap = getStepHashMap();
			m_goalMap = getGoalHashMap();

			/*
			 * m_step1 = 350; m_step2 = 300; m_step3 = 400;
			 */

			// m_RotateAnimation = new RotateAnimation(0.0f, 360.0f,
			// Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			// 0.5f);
			m_Bmp = BitmapFactory.decodeResource(getResources(),
					R.drawable.sunny);
			// this.setFocusable(false);
			// this.setClickable(false);

		}

		// Init from xml need the Constructor with two params
		public DataDrawView(Context context, AttributeSet attrs) {
			super(context, attrs);

			WindowManager manager = (WindowManager) context
					.getSystemService(Context.WINDOW_SERVICE);
			Display display = manager.getDefaultDisplay();
			m_width = display.getWidth();
			m_height = display.getHeight();

			/*
			 * m_step1 = 350; m_step2 = 300; m_step3 = 400;
			 */
			m_stepMap = getStepHashMap();
			m_goalMap = getGoalHashMap();
			// m_RotateAnimation = new RotateAnimation(0.0f, 360.0f,
			// Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			// 0.5f);
			m_Bmp = BitmapFactory.decodeResource(getResources(),
					R.drawable.sunny);
			//
			// //this.setFocusable(true);
			// this.setClickable(false);
		}
		
		//Calendar转换为Date,只保留年月日部分，其余字段清零,注意还要减去时区的毫秒差
		private Date dateConvert(Calendar calendar){
			long timeInMil = calendar.getTimeInMillis();
			timeInMil = timeInMil - timeInMil%(24*3600*1000) - calendar.getTimeZone().getOffset(timeInMil);
			return new Date(timeInMil);
		}

		public void setCurCalendar(Calendar calendar) {
			
			// Deep clone
			m_curCalendar = (Calendar) calendar.clone();
			// m_curCalendar.add(Calendar.DATE, 1);
//			m_curDate = m_curCalendar.getTime();
//			m_curCalendar.add(Calendar.DATE, -1);
//			m_thedaybefore = m_curCalendar.getTime();
//			m_curCalendar.add(Calendar.DATE, -1);
//			m_3daysbefore = m_curCalendar.getTime();
			m_curDate = dateConvert(m_curCalendar);
			m_curCalendar.add(Calendar.DATE, -1);
			m_thedaybefore = dateConvert(m_curCalendar);
			m_curCalendar.add(Calendar.DATE, -1);
			m_3daysbefore = dateConvert(m_curCalendar);
		}

		public void setSteps() {

			Log.v(TAG, String.valueOf(m_stepMap == null ? 0 : 1));
			Log.v(TAG, String.valueOf(m_goalMap == null ? 0 : 1));
			Log.v(TAG, m_curDate.toString());
			if(m_stepMap.get(m_curDate) == null){
				m_step1 = 0;
				m_goal1 = 1;
			}
			else{
				m_step1 = m_stepMap.get(m_curDate);
				//m_goal1 = m_goalMap.get(m_curDate);
				m_goal1 = 3000;
			}
				
			
			if(m_stepMap.get(m_thedaybefore) == null){
				m_step2 = 0;
				m_goal2 = 1;
			}
			else{
				m_step2 = m_stepMap.get(m_thedaybefore);
				//m_goal2 = m_goalMap.get(m_thedaybefore);
				m_goal2 = 3000;
			}
			
			if(m_stepMap.get(m_3daysbefore) == null){
				m_step3 = 0;
				m_goal3 = 1;
			}
			else{
				m_step3 = m_stepMap.get(m_3daysbefore);
				//m_goal3 = m_goalMap.get(m_3daysbefore);
				m_goal3 = 3000;
			}

		}

		/*
		 * public void setDataMap(HashMap<Date, Integer> hashmap){ m_datamap =
		 * (HashMap<Date, Integer>)hashmap.clone(); }
		 */
		public void setSteps2(List<StepData> ds1) {

		}

		/*public void setGoal(int goal) {
			m_goal = goal;
		}*/

		/*
		 * private RefreshHandler mRedrawHandler = new RefreshHandler();
		 * 
		 * class RefreshHandler extends Handler{
		 * 
		 * @Override public void handleMessage(Message msg) {
		 * super.handleMessage(msg); if(msg.what == messageWhat) invalidate(); }
		 * };
		 * 
		 * public void update(){ Message msg = new Message(); msg.what =
		 * messageWhat; mRedrawHandler.sendMessage(msg); }
		 */

		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
			float width, height;
			width = m_width;
			height = m_height;
			Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

			/*
			 * 这里将绘制计步箭头图形。分别绘制坐标，日期文字，箭头，计步数据和计步百分比
			 * 注意考虑屏幕的适配，这里将屏幕全高划分为24,全宽为16
			 * QVGA(320:240),HVGA(480:320),VGA(640:480),WVGA(800:480)
			 */
			// Draw coordinate
			/*
			 * Fixed px draw
			 * 
			 */
			paint.setColor(Color.BLACK);
			paint.setStyle(Paint.Style.FILL);
			canvas.drawLine(0, m_height - height * 8 / 24, m_width, m_height
					- height * 8 / 24, paint);

			// Draw Date Text
			paint.setColor(Color.BLACK);
			paint.setTextSize(16 * width / 320);
			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
			String curday = format.format(m_curDate);
			canvas.drawText(curday, width / 2 + width * 3 / 16, m_height
					- height * 7 / 24, paint);

			String yestoday = format.format(m_thedaybefore);
			canvas.drawText(yestoday, width / 2 - width * 2 / 16, m_height
					- height * 7 / 24, paint);

			String beforeyestoday = format.format(m_3daysbefore);
			canvas.drawText(beforeyestoday, width / 2 - width * 7 / 16,
					m_height - height * 7 / 24, paint);

			// Draw arrow , order from right to left, which according to percent
			int percent1 = (int) ((float) m_step1 / m_goal1 * 100);
			int percent2 = (int) ((float) m_step2 / m_goal2 * 100);
			int percent3 = (int) ((float) m_step3 / m_goal3 * 100);
			paint.setColor(Color.RED);
			Path mPath = new Path();
			int rowHighPercent1;
			if (percent1 >= 100)
				rowHighPercent1 = 100;
			else
				rowHighPercent1 = percent1;
			mPath.moveTo(width / 2 + width * 3 / 16, m_height - height * 8 / 24);
			mPath.lineTo(width / 2 + width * 7 / 16, m_height - height * 8 / 24);
			mPath.lineTo(width / 2 + width * 7 / 16, m_height - height * 8 / 24
					- height * 4 / 24 - height * rowHighPercent1 * (float) 0.08
					/ 24);
			mPath.lineTo(width / 2 + width * 5 / 16, m_height - height * 8 / 24
					- height * 4 / 24 - height * rowHighPercent1 * (float) 0.08
					/ 24 - height * 2 / 24);
			mPath.lineTo(width / 2 + width * 3 / 16, m_height - height * 8 / 24
					- height * 4 / 24 - height * rowHighPercent1 * (float) 0.08
					/ 24);
			mPath.lineTo(width / 2 + width * 3 / 16, m_height - height * 8 / 24);
			mPath.close();
			canvas.drawPath(mPath, paint);

			// Draw arrow 2
			int rowHighPercent2;
			if (percent2 >= 100)
				rowHighPercent2 = 100;
			else
				rowHighPercent2 = percent2;
			mPath.moveTo(width / 2 - width * 2 / 16, m_height - height * 8 / 24);
			mPath.lineTo(width / 2 + width * 2 / 16, m_height - height * 8 / 24);
			mPath.lineTo(width / 2 + width * 2 / 16, m_height - height * 8 / 24
					- height * 4 / 24 - height * rowHighPercent2 * (float) 0.08
					/ 24);
			mPath.lineTo(width / 2, m_height - height * 8 / 24 - height * 4
					/ 24 - height * rowHighPercent2 * (float) 0.08 / 24
					- height * 2 / 24);
			mPath.lineTo(width / 2 - width * 2 / 16, m_height - height * 8 / 24
					- height * 4 / 24 - height * rowHighPercent2 * (float) 0.08
					/ 24);
			mPath.lineTo(width / 2 - width * 2 / 16, m_height - height * 8 / 24);
			mPath.close();
			canvas.drawPath(mPath, paint);

			// Draw arrow 3
			int rowHighPercent3;
			if (percent3 >= 100)
				rowHighPercent3 = 100;
			else
				rowHighPercent3 = percent3;
			mPath.moveTo(width / 2 - width * 7 / 16, m_height - height * 8 / 24);
			mPath.lineTo(width / 2 - width * 3 / 16, m_height - height * 8 / 24);
			mPath.lineTo(width / 2 - width * 3 / 16, m_height - height * 8 / 24
					- height * 4 / 24 - height * rowHighPercent3 * (float) 0.08
					/ 24);
			mPath.lineTo(width / 2 - width * 5 / 16, m_height - height * 8 / 24
					- height * 4 / 24 - height * rowHighPercent3 * (float) 0.08
					/ 24 - height * 2 / 24);
			mPath.lineTo(width / 2 - width * 7 / 16, m_height - height * 8 / 24
					- height * 4 / 24 - height * rowHighPercent3 * (float) 0.08
					/ 24);
			mPath.lineTo(width / 2 - width * 7 / 16, m_height - height * 8 / 24);
			mPath.close();
			canvas.drawPath(mPath, paint);

			// Draw step text
			paint.setColor(Color.WHITE);
			paint.setTextSize(24 * width / 320);
			paint.setTypeface(Typeface.SANS_SERIF);
			canvas.drawText(String.valueOf(m_step1), width / 2 + width
					* (float) 3.5 / 16, m_height - height * 9 / 24, paint);
			canvas.drawText(String.valueOf(m_step2), width / 2 - width
					* (float) 1.5 / 16, m_height - height * 9 / 24, paint);
			canvas.drawText(String.valueOf(m_step3), width / 2 - width
					* (float) 6.5 / 16, m_height - height * 9 / 24, paint);

			// Draw goals precent text
			canvas.drawText(String.valueOf(percent1) + "%", width / 2 + width
					* (float) 3.5 / 16, m_height - height * 8 / 24 - height * 4
					/ 24 - height * rowHighPercent1 * (float) 0.08 / 24
					+ height * 1 / 24, paint);
			canvas.drawText(String.valueOf(percent2) + "%", width / 2 - width
					* (float) 1.5 / 16, m_height - height * 8 / 24 - height * 4
					/ 24 - height * rowHighPercent2 * (float) 0.08 / 24
					+ height * 1 / 24, paint);
			canvas.drawText(String.valueOf(percent3) + "%", width / 2 - width
					* (float) 6.5 / 16, m_height - height * 8 / 24 - height * 4
					/ 24 - height * rowHighPercent3 * (float) 0.08 / 24
					+ height * 1 / 24, paint);

			if (percent1 >= 100)
				canvas.drawBitmap(m_Bmp,
						width / 2 + width * 5 / 16 - m_Bmp.getWidth() / 2,
						m_height - height * 8 / 24 - height * 4 / 24 - height
								* rowHighPercent1 * (float) 0.08 / 24 - height
								* 2 / 24 - m_Bmp.getHeight() / 2, paint);

			if (percent2 >= 100)
				canvas.drawBitmap(m_Bmp, width / 2 - m_Bmp.getWidth() / 2,
						m_height - height * 8 / 24 - height * 4 / 24 - height
								* rowHighPercent2 * (float) 0.08 / 24 - height
								* 2 / 24 - m_Bmp.getHeight() / 2, paint);

			if (percent3 >= 100)
				canvas.drawBitmap(m_Bmp,
						width / 2 - width * 5 / 16 - m_Bmp.getWidth() / 2,
						m_height - height * 8 / 24 - height * 4 / 24 - height
								* rowHighPercent3 * (float) 0.08 / 24 - height
								* 2 / 24 - m_Bmp.getHeight() / 2, paint);

		}

		@Override
		public boolean onKeyDown(int keyCode, KeyEvent event) {
			if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
				m_RotateAnimation.initialize(m_Bmp.getWidth(),
						m_Bmp.getHeight(), m_width, m_height);
				m_RotateAnimation.setDuration(3000);
				this.startAnimation(m_RotateAnimation);
			}
			return super.onKeyDown(keyCode, event);
		}

		// Arrow Click event, into the history page
		/*
		 * public boolean onTouchEvent (MotionEvent event){
		 * if(mGestureDetector.onTouchEvent(event)) return true; else{ int x =
		 * (int)event.getX(); int y = (int)event.getY();
		 * 
		 * Rect step1Rect, step2Rect, step3Rect; step1Rect = new
		 * Rect(m_width/2+60+10, m_height-m_step1-300,m_width/2+160+10,
		 * m_height-300); step2Rect = new Rect(m_width/2-50,
		 * m_height-m_step2-300,m_width/2+50, m_height-300); step3Rect = new
		 * Rect(m_width/2-160-10, m_height-m_step3-300,m_width/2-60-10,
		 * m_height-300);
		 * 
		 * if(step1Rect.contains(x, y) || step2Rect.contains(x,y) ||
		 * step3Rect.contains(x, y)){ Intent intent = new Intent();
		 * intent.setClass(DataViewActivity.this, DataHistoryActivity.class);
		 * startActivity(intent); } return super.onTouchEvent(event); }
		 * 
		 * }
		 */
	}

	//监听蓝牙手表数据传输过程的事件处理程序
	public void onReceive(Object notifyObj, String evenName, Intent data) {
       Toast.makeText(this, evenName, Toast.LENGTH_LONG).show();
		if(evenName.equals(BluetoothService.BLUETOOH_DISABLE)){
			Toast.makeText(DataViewActivity.this, "请打开本地蓝牙接口！", 2000).show();
		}
       
		if(evenName.equals(BluetoothService.DEVICE_FOUND)){
			//((BluetoothService) notifyObj).setState(BTSTATE.DEVICE_FOUND);
			bluetoothService.doPair();
			}
		if(evenName.equals(BluetoothService.DoPairSucess)){
		//((BluetoothService) notifyObj).setState(BTSTATE.DEVICE_FOUND);
		bluetoothService.doSendFileByBluetooth();
		}
		
	}
}
